package Exception3;

public class StudentWithException {
    public StudentWithException(int age) throws InvalidAgeException{
        setAge(age);
        objectCount++;
    }

    private int age;
    static private int objectCount;

    public static int getObjectCount() {
        return objectCount;
    }

    public void setAge(int age) throws InvalidAgeException{
        if(age <= 0){
            throw new InvalidAgeException(age);
        }
        this.age = age;
    }
}

